package com.bs.bsacexj.web.controller;



import com.bs.bsacexj.common.constant.Constants;
import com.bs.bsacexj.common.core.domain.AjaxResult;
import com.bs.bsacexj.common.core.redis.RedisCache;
import com.bs.bsacexj.domain.AccessControlDeviceInfoVO;
import com.bs.bsacexj.domain.AccessControlEventInfoVO;
import com.bs.bsacexj.domain.PersonInfoVO;
import com.bs.bsacexj.service.impl.UploadACEventInfoService;
import com.bs.bsacexj.service.impl.UploadBaseDataServices;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("/debugUpload")
public class DebugUploadDataController {
    @Autowired
    UploadACEventInfoService uploadACEventInfoService;

    @Autowired
    UploadBaseDataServices uploadBaseDataServices;

    @Value("${siteInfo.siteId}")
    private String siteId;

    @Autowired
    RedisCache  redisCache;
    @GetMapping("/uploadACEventInfo")
    public AjaxResult uploadACEventInfo() throws Exception {
        AccessControlEventInfoVO vo = new AccessControlEventInfoVO();
        vo.setOrgId(siteId);
        vo.setCardNo("11111");
        vo.setDoorIndexCode("1111");
        vo.setDoorName("1111");
        vo.setDoorRegionIndexCode("1111");
        vo.setEventTime("2024-08-10 12:00:00+08:00");
        vo.setEventId("123");
        vo.setEventName("1111");
        vo.setEventTime("2024-08-10 12:00:00+08:00");
        vo.setEventType("111");
        vo.setIdentityCardUri("1111");
        vo.setInAndOutType("1111");
        vo.setOrgName("123");
        vo.setPersonId("1111");
        vo.setPicUri("1111");
        vo.setSvrIndexCode("1111");

        List<AccessControlEventInfoVO> paramList=new ArrayList();
        paramList.add(vo);
        boolean result= uploadACEventInfoService.uploadACEventInfo(paramList);
        if(result){
            return AjaxResult.success();
        }else {
            return AjaxResult.error();
        }
    }

    @GetMapping("/uploadACDevice")
    public AjaxResult uploadACDevice() throws Exception {
        List<AccessControlDeviceInfoVO> paramList=new ArrayList();

        boolean result= uploadBaseDataServices.uploadACDeviceInfo(paramList);
        if(result){
            return AjaxResult.success();
        }else {
            return AjaxResult.error();
        }
    }

    @GetMapping("/uploadPerson")
    public AjaxResult uploadPerson() throws Exception {
        PersonInfoVO vo = new PersonInfoVO();
        List<PersonInfoVO> paramList=new ArrayList();
        boolean result= uploadBaseDataServices.uploadUserInfo(paramList);
        if(result){
            return AjaxResult.success();
        }else {
            return AjaxResult.error();
        }
    }

    //测试批量上传门禁数据
    @GetMapping("/uploadBatchACEventInfo")
    public AjaxResult uploadBatchACEventInfo() throws Exception {
        List<AccessControlEventInfoVO> paramList = new ArrayList();
        for(int i=0;i<20;i++) {
            AccessControlEventInfoVO vo = new AccessControlEventInfoVO();
            vo.setOrgId(siteId);
            vo.setCardNo(String.valueOf(i));
            vo.setDoorIndexCode(String.valueOf(i));
            vo.setDoorName(String.valueOf(i));
            vo.setDoorRegionIndexCode(String.valueOf(i));
            vo.setEventTime("2024-08-10 12:00:00+08:00");
            vo.setEventId(String.valueOf(i));
            vo.setEventName(String.valueOf(i));
            vo.setEventTime("2024-08-10 12:00:00+08:00");
            vo.setEventType(String.valueOf(i));
            vo.setIdentityCardUri(String.valueOf(i));
            vo.setInAndOutType(String.valueOf(i));
            vo.setOrgName(String.valueOf(i));
            vo.setPersonId(String.valueOf(i));
            vo.setPicUri(String.valueOf(i));
            vo.setSvrIndexCode(String.valueOf(i));
            paramList.add(vo);
            redisCache.rPush(Constants.WAIT_ACEEVENT_RECORD_KEY,vo);
        }
//        boolean result= uploadACEventInfoService.uploadACEventInfo(paramList);
        boolean result=true;

        if(result){
            return AjaxResult.success();
        }else {
            return AjaxResult.error();
        }
    }


}